package com.android.jianboshi.dialog;

import android.view.View;
import android.widget.TextView;

import androidx.fragment.app.FragmentActivity;

import com.android.baselibrary.dialog.BaseDialogFragment;
import com.android.baselibrary.tool.SPUtil;
import com.android.jianboshi.R;
import com.android.jianboshi.constants.SPConstants;
import com.android.jianboshi.manager.BoxingHelper;

import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 拳力记录
 */

public class Boxing_PowerResult_DialogFragment extends BaseDialogFragment {

    @BindView(R.id.tv_content)
    TextView tv_content;

    public static final String Param_Power = "Param_Power";

    double power;

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_boxing_power_result;
    }

    @Override
    protected void initData() {
        power = BoxingHelper.getPowerByUnit(mContext,power);
        //设置单位
        int unit = SPUtil.getIntValue(mContext, SPConstants.Unit, 0);
        String unitStr = "";
        if (unit == 0) {
            unitStr = getString(R.string.power_unit_unit1);
        } else {
            unitStr = getString(R.string.power_unit_unit2);
        }
        String text = (int) power + " "+ unitStr;

        tv_content.setText(text);
    }

    @Override
    protected void initView() {
    }

    @Override
    protected boolean setCanceledOnTouchBACK() {
        return true;
    }

    @Override
    protected int getShowDirection() {
        return BaseDialogFragment.Direction_FadeIn;
    }

    @Override
    public void setData(Map<String, Object> params) {
        if (params != null) {
            power = (double) params.get(Boxing_PowerResult_DialogFragment.Param_Power);


        }
    }

    public static BaseDialogFragment showDialog(FragmentActivity activity, Map<String, Object> params) {
        Boxing_PowerResult_DialogFragment dialogFragment = new Boxing_PowerResult_DialogFragment();
        dialogFragment.setData(params);
        dialogFragment.show(activity.getSupportFragmentManager(), "");
        return dialogFragment;
    }


    @OnClick({R.id.csb_ok})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.csb_ok:  //确定
                dismissWithAnim();
                break;
        }
    }


}
